﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace EMC
{
    public class databaseConfiguration
    {
        //Connection details
        public string dbType;
        public string dbConnectionString;

        //Details for the users table
        public string tableUsers;
        public string tableUsers_ID;
        public string tableUsers_FirstName;
        public string tableUsers_LastName;
        public string tableUsers_Password;
        public string tableUsers_Email;
        public string tableUsers_Phone;

        //Details for the files table
        public string tableFiles;
        public string tableFiles_Fileid;
        public string tableFiles_UserID;
        public string tableFiles_Filename;
        public string tableFiles_Description;

        //Details for the friends table
        public string tableFriends;
        public string tableFriends_UserID1;
        public string tableFriends_UserID2;
        

        //Constructs the class from an XML file
        public databaseConfiguration(string xmlFile)
        {
            //Open the XML file
            XmlDocument xml = new XmlDocument();
            xml.Load(xmlFile);
            XmlNode settings = xml.FirstChild;

            //Load in the data (will throw an exception if you supply a malformed file)
            dbType = settings["dbType"].InnerXml;
            dbConnectionString = settings["dbConnectionString"].InnerXml;

            tableUsers = settings["tableUsers"].InnerXml;
            tableUsers_ID = settings["tableUsers_ID"].InnerXml;
            tableUsers_FirstName = settings["tableUsers_FirstName"].InnerXml;
            tableUsers_LastName = settings["tableUsers_LastName"].InnerXml;
            tableUsers_Password = settings["tableUsers_Password"].InnerXml;
            tableUsers_Email = settings["tableUsers_Email"].InnerXml;
            tableUsers_Phone = settings["tableUsers_Phone"].InnerXml;

            tableFiles = settings["tableFiles"].InnerXml;
            tableFiles_Fileid = settings["tableFiles_Fileid"].InnerXml;
            tableFiles_UserID = settings["tableFiles_UserID"].InnerXml;
            tableFiles_Filename = settings["tableFiles_Filename"].InnerXml;
            tableFiles_Description = settings["tableFiles_Description"].InnerXml;

            tableFriends = settings["tableFriends"].InnerXml;
            tableFriends_UserID1 = settings["tableFriends_UserID1"].InnerXml;
            tableFriends_UserID2 = settings["tableFriends_UserID2"].InnerXml;
        }
    }
}
